; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals
; RUN: opt -S -passes=globalopt < %s | FileCheck %s

; The store here writes into the padding after [5 x i8].
; Make sure we don't crash.

%T = type { [5 x i8], i16 }

@g = global %T zeroinitializer

@llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @ctor, ptr null }]

;.
; CHECK: @[[G:[a-zA-Z0-9_$"\\.-]+]] = local_unnamed_addr global [[T:%.*]] zeroinitializer
; CHECK: @[[LLVM_GLOBAL_CTORS:[a-zA-Z0-9_$"\\.-]+]] = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @ctor, ptr null }]
;.
define internal void @ctor() {
; CHECK-LABEL: @ctor(
; CHECK-NEXT:    store i8 0, ptr getelementptr inbounds ([[T:%.*]], ptr @g, i64 0, i32 0, i64 5), align 1
; CHECK-NEXT:    ret void
;
  store i8 0, ptr getelementptr inbounds (%T, ptr @g, i64 0, i32 0, i64 5)
  ret void
}
